/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.config.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.config.dto.ConfigElectricArchiveCatalogSaveDto;
import com.icinfo.cloud.provider.punish.config.model.ConfigElectricArchiveCatalogDetail;
import com.icinfo.cloud.provider.punish.config.service.IConfigElectricArchiveCatalogDetailService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 描述: 电子卷宗配置目录信息 config_electric_archive_catalog_detail 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年12月08日
 */
@RestController
@RequestMapping("/punish/config/electricArchive/catalog")
@Slf4j
public class ConfigElectricArchiveCatalogDetailController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(ConfigElectricArchiveCatalogDetailController.class);

    @Autowired
    private IConfigElectricArchiveCatalogDetailService configElectricArchiveCatalogDetailService;

    /**
     * 【V1.9.4】描述：查询电子卷宗目录配置信息列表
     *
     * @return {@link Result < List <ConfigDeptParamKeyInfoVo>>} 已配置的部门关键信息列表
     * @author xiangyuyu
     * @date 2022-05-16 16:16
     */
    @GetMapping("/getElectricArchiveCatalog")
    @ApiOperation(value = "【V2.0.0】描述：查询电子卷宗目录配置信息列表", httpMethod = "GET")
    public Result<List<ConfigElectricArchiveCatalogDetail>> getElectricArchiveCatalog(String archiveId) {
        return Result.success(Constant.STRING_GET_SUCCESS, configElectricArchiveCatalogDetailService.getElectricArchiveCatalog(archiveId));
    }

    /**
     * 【V1.9.4】描述：保存电子卷宗目录配置信息
     *
     * @return {@link Result < List <ConfigDeptParamKeyInfoVo>>} 已配置的部门关键信息列表
     * @author xiangyuyu
     * @date 2022-05-16 16:16
     */
    @PostMapping("/saveElectricArchiveCatalog")
    @ApiOperation(value = "【V2.0.0】描述：保存电子卷宗目录配置信息", httpMethod = "POST")
    public Result<List<ConfigElectricArchiveCatalogDetail>> saveElectricArchiveCatalog(@RequestBody @Validated ConfigElectricArchiveCatalogSaveDto saveDto) {
        int i = configElectricArchiveCatalogDetailService.saveElectricArchiveCatalog(saveDto);
        if (i > 0) {
            return Result.success(Constant.STRING_SAVE_SUCCESS);
        }
        return Result.error(Constant.STRING_SAVE_FAIL);
    }
}
